home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3210 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.4 KB  |  57 lines

  1. Path: news-m01.ny.us.ibm.net!usenet
  2. From: cmahony@ibm.net (Colin Mahoney)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: seeking for c++ private base class inheritance examples
  5. Date: Mon, 22 Jan 1996 21:39:01 GMT
  6. Message-ID: <4e0um6$1fl6@news-s01.ny.us.ibm.net>
  7. References: <DL270x.KL9@hkpu01.polyu.edu.hk>
  8. NNTP-Posting-Host: slip139-92-41-247.emea.ibm.net
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. Sit Kwok Fu <cskfsit> wrote:
  12.  
  13. >Hi,
  14. >    This is my first time to ask for assistance by newsgroup. I am doing some
  15. >study about c++ private base class inheritance, but I could not find some good
  16. >examples and source codes to show the different situations of this kind of
  17. >inheritance.  Does anybody know where I can grap some?
  18.  
  19.  
  20. >sit
  21. >Hong Kong Polytechnic University
  22.  
  23. You can use private inheritance to inherit 'behaviour'.
  24.  
  25. for example, I have a class which is more or less as follows:
  26.  
  27. class Modeless
  28.     {
  29.     static List<const HWND&> WindowList;
  30.  
  31.     const HWND& hwndRef;    
  32.  
  33. public:
  34.     Modeless( const HWND& hwnd ):
  35.         hwndRef( hwnd )
  36.         {
  37.         WindowList.Add( hwnd );
  38.         }
  39.     ~Modeless()
  40.         {
  41.         WindowList.Remove( hwndRef );
  42.         }
  43.  
  44.     static BOOL CheckMessage( LPMSG lpmsg );
  45.     };
  46.  
  47. I derive privately any windows I want to behave 'modelessly' ( ie have windows
  48. handle tabs etc for ) from this, then call 'CheckMessage' in my main event loop.
  49. There are no doubt other ways of doing this, but this one is easy to use and
  50. very flexible.
  51.  
  52. --
  53. Colin Mahoney    ( cmahony@ibm.net )
  54. Sabadell, Barcelona
  55. --
  56.  
  57.